package com.emergency.db.dao.staff;

import com.emergency.db.domain.staff.StaffDetail;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

@Transactional
public interface StaffDetailDao extends JpaRepository<StaffDetail, Long>, JpaSpecificationExecutor<StaffDetail> {
    @Modifying
    @Query(value = "delete FROM bas_staff_detail WHERE staff_id = ? ", nativeQuery = true)
    void deleteByStaff(Long id);

    @Query("select sd from StaffDetail sd where staff.id=:id ")
    StaffDetail findByStaff(@Param("id") Long id);
}
